** matching gas stations and wholesale regions


clear
import delimited "$P_Data/Wholesale Price Data/region_lat_long.csv", encoding(UTF-8) 


cross using  "$P_Data/Data/GS/gas_station.dta"

drop if Lat==.

geodist reg_lat reg_long Lat Lng, generate(distance)


sort StID distance
by StID: keep if _n==1

rename distance wholesale_distance

keep StID region wholesale_distance
save "$P_Data_Processed/wholesale_price_concordance.dta", replace


** getting daily wholesale price data

import excel "$P_Data/Wholesale Price Data/E5_formatted.xlsx", sheet("Sheet1") firstrow clear

rename daily_date date
drop Einheit
drop Produkt

rename low_wh_price low_w_price

gener mean_w_price = (low_w_price+ high_w_price)/2

replace low_w_price = low_w_price/100
replace high_w_price = high_w_price/100
replace mean_w_price = mean_w_price/100

save "$P_Data_Processed/wholesale_price_e5.dta", replace 
